package com.richfit.barcodesystem_cczt.activitis.adapters;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import com.richfit.barcodesystem_cczt.databinding.LayoutZboxDetailBinding;
import com.richfit.barcodesystem_cczt.fragments.model.ZBoxEntity;

import java.util.List;

public class Detail_Adapter extends BaseAdapter {
    private LayoutZboxDetailBinding binding;
    private Context mContext;
    private List<ZBoxEntity.Detail> list;

    public Detail_Adapter(Context context, List<ZBoxEntity.Detail> list) {
        this.mContext = context;
        this.list = list;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public ZBoxEntity.Detail getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View view, ViewGroup parent) {
        if (view == null) {
            binding = LayoutZboxDetailBinding.inflate(LayoutInflater.from(mContext));
            view = binding.getRoot();
            view.setTag(binding);
        } else {
            binding = (LayoutZboxDetailBinding) view.getTag();
        }
        ZBoxEntity.Detail detail = getItem(position);
        //物料编码
        binding.TxtaterialId.setText(detail.getMaterialNum());
        //计量单位
        binding.TxtUnit.setText(detail.getUnit());
        //中文描述
        binding.TxtPackingSpec.setText(detail.getMaterialDesc());
        //外文描述
        binding.TxtMaterialEdesc.setText(detail.getMaterialEdesc());
        //单价
        binding.TxtPrice.setText(detail.getPrice() + "");
        //金额
        binding.TxtAmount.setText(detail.getAmount() + "");
        //生产厂家
        binding.TxtManufacturer.setText(detail.getManufacturer());
        //生产日期
        binding.TxtProductionDate.setText(detail.getProductionDate().substring(0, 10));
        //供应商名称
        binding.TxtSupplierDesc.setText(detail.getSupplierDesc());
        //合同号
        binding.TxtContractNum.setText(detail.getContractNum());
        //采购订单
        binding.TxtPoNum.setText(detail.getPoNum());
        //采办人
        binding.TxtPoCreatorName.setText(detail.getPoCreatorName());
        //需求小队
        binding.TxtTeamName.setText(detail.getTeamName());
        return view;
    }
}
